import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'FunctionModel.dart';

class ListPage extends StatefulWidget {
  String title;
  List<FunctionModel> list;

  ListPage(this.title, this.list);

  @override
  _ListPageState createState() => _ListPageState();
}

class _ListPageState extends State<ListPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: ListView.builder(
        itemCount: widget.list.length,
        itemBuilder: (ctx, i) => TextButton(
          child: Text(
            '${widget.list[i].title}',
            style: TextStyle(color: Colors.black),
          ),
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(
                builder: (context) => widget.list[i].page,
              ),
            );
          },
        ),
      ),
    );
  }
}
